/**
 * User only
 */
Ext.Loader.setConfig({enabled: true});
Ext.Loader.setPath('Ext.ux', baseUrl + '/extjs/ux');
Ext.require([
     'Ext.ux.LiveSearchGridPanel'
 ]);
Ext.define('Cps.view.dashboard.Dashboard', {
	extend : 'Ext.panel.Panel',
	alias : 'widget.dashboard',
	layout: 'vbox',

	id: 'dashboard',
	title : Cps.Locale.Dashboard.title,
	
	tools: [
        {
            type: 'lang-en',
            width: 21,
            height: 15,
            renderTpl: [
                '<img id="{id}-toolEl" src="{blank}" class="{baseCls} flag flag-gb" role="presentation"/>',
                ''
            ],
            handler: function () {
            	changeLanguage('en');
            }
        },
        {
            type: 'lang-fr',
            width: 21,
            height: 15,
            renderTpl: [
                '<img id="{id}-toolEl" src="{blank}" class="{baseCls} flag flag-fr" role="presentation"/>',
                ''
            ],
            handler: function () {
            	changeLanguage('fr');
            }
        },
        {
    		type: 'close',
        	tooltip: Cps.Locale.LOGOUT,
            handler: function(event, toolEl, panelHeader) {
                location.href = baseUrl + '/user/logout';
            }
        }
	],
	
    initComponent: function() {
    	var years = [];
    	var y = 2005;
    	while (y<=2013){
    	     years.push([y]);
    	     y++;
    	}
    	
    	var months = [];
    	var m = 1
    	while (m<=12){
    		months.push([m, Cps.Locale.MONTHFULLSTR[m]]);
    	    m++;
    	}
    	var now = new Date();
    	var curmonth = now.getMonth();
    	
    	this.items = [
	    		{
	    			xtype: 'form',
	    			frame: true,
	    			title: Cps.Locale.Dashboard.title_filter,
	    			width: '100%',
	    			bodyPadding: 5,
	    			fieldDefaults: {
	    	            labelAlign: 'left',
	    	            labelWidth: 90,
	    	            anchor: '100%'
	    	        },
                    items: [{
                        xtype: 'container',
                        layout: 'hbox',
                        items: [
                            {
                                xtype: 'container',
                                layout: 'vbox',
                                items: [
                                    {
                                        xtype: 'textfield',
                                        allowBlank: false,
                                        fieldLabel: Cps.Locale.Dashboard.filter_companies,
                                        emptyText: Cps.Locale.Dashboard.filter_companies,
                                        name: 'companies',
                                        id: 'companies',
                                        margins: '0 0 0 5'
                                    },
                                    {
                                        xtype: 'textfield',
                                        allowBlank: true,
                                        fieldLabel: Cps.Locale.Dashboard.filter_account,
                                        emptyText: Cps.Locale.Dashboard.filter_account,
                                        name: 'account',
                                        id: 'account',
                                        margins: '0 0 0 5'
                                    }
                                    ]
                            },
                            {
                                xtype: 'container',
                                layout: 'vbox',
                                margins: '0 0 0 5',
                                items: [
                                    {
                                        xtype: 'radiofield',
                                        boxLabel: Cps.Locale.Dashboard.filter_value_date,
                                        name: 'value',
                                        inputValue: 1,
                                        id: 'value1',
                                        checked: true
                                    },
                                    {
                                        xtype: 'radiofield',
                                        boxLabel: Cps.Locale.Dashboard.filter_value_trade,
                                        name: 'value',
                                        inputValue: 0,
                                        id: 'value2'
                                    }
                                ]
                            },
                            {
                                xtype: 'container',
                                layout: 'vbox',
                                margins: '0 0 0 5',
                                items: [
                                    {
                                        xtype: 'datefield',
                                        fieldLabel: '',
                                        name: 'date_value',
                                        id: 'date_value'
                                    },
                                    {
                                        xtype: 'datefield',
                                        fieldLabel: '',
                                        name: 'date_trade',
                                        id: 'date_trade'
                                    }
                                ]
                            },
                            {
                                xtype: 'container',
                                layout: 'vbox',
                                margins: '0 0 0 5',
                                items: [
                                    {
                                        xtype: 'checkboxfield',
                                        fieldLabel: Cps.Locale.Dashboard.filter_centralaccount,
                                        name: 'centralaccount',
                                        id: 'centralaccount',
                                        labelWidth: 'auto'
                                    },
                                    {
                                        xtype: 'textfield',
                                        fieldLabel: Cps.Locale.Dashboard.filter_group,
                                        name: 'group',
                                        id: 'group',
                                        labelWidth: 'auto'
                                    }
                                    ]
                            },
                        /*{
                            xtype: 'radiogroup',
                            fieldLabel: 'Date action',
                            itemId: 'value1',
                            columns: 2,
                            items: [
                                {
                                    xtype: 'radiofield',
                                    boxLabel: Cps.Locale.Dashboard.filter_value_date,
                                    name: 'value',
                                    checked: true,
                                    inputValue: 1
                                },
                                {
                                    xtype: 'radiofield',
                                    boxLabel: Cps.Locale.Dashboard.filter_value_trade,
                                    name: 'value',
                                    inputValue: 0
                                }
                            ]
                        },*/
                        {
                            xtype: 'button',
                            text: Cps.Locale.Dashboard.filter_btnview,
                            scale: 'large',
                            action: 'report',
                            formBind: true,
                            disabled: true,
                            margins: '0 0 0 5'
                        }]
                    }]
	    		},
	    		{
	    			xtype: 'panel',
	    			flex: 1,
	    			id: 'resultCtn',
	    			//autoScroll: true,
                    width: '100%',
	    			height: '100%',
	    			layout: 'fit'
	    		}
	    ];
    	
    	this.callParent(arguments);
    }
});